package com.srd.phone.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


public class TenderRecordInfo implements Serializable {

    public String id;
    public String state;
    public String symbol;
    public String userName;
    public String stat;
    public String stime;
    public String numbers;
    public String uid;
    public double moneys;
    public String nm;
    public String mid;
    public String style;
    public String profit;
    public String numbersm; //一次性还款
    public String statem; //回款成功
    public String statm; //招标中

    public static List<TenderRecordInfo> parse(String json) {
        List<TenderRecordInfo> list = new ArrayList<>();
        try {
            JSONArray jsonArray = new JSONArray(json);
            for (int i = 0; i < jsonArray.length(); i++) {
                TenderRecordInfo recordInfo = new TenderRecordInfo();
                JSONObject jsonObject = jsonArray.getJSONObject(i);
                recordInfo.id = jsonObject.optString("id");
                recordInfo.state = jsonObject.optString("state");
                recordInfo.symbol = jsonObject.optString("symbol");
                recordInfo.userName = jsonObject.optString("userName");
                recordInfo.stat = jsonObject.optString("stat");
                recordInfo.stime = jsonObject.optString("stime");
                recordInfo.numbers = jsonObject.optString("numbers");
                recordInfo.uid = jsonObject.optString("uid");
                recordInfo.moneys = jsonObject.optDouble("moneys",0);
                recordInfo.nm = jsonObject.optString("nm");
                recordInfo.mid = jsonObject.optString("mid");
                recordInfo.style = jsonObject.optString("style");
                recordInfo.profit = jsonObject.optString("profit");
                recordInfo.numbersm = jsonObject.optString("numbersm");
                recordInfo.statem = jsonObject.optString("statem");
                recordInfo.statm = jsonObject.optString("statm");
                list.add(recordInfo);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return list;
    }
}
